package ericXie.com.command 
{

	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import ericXie.com.bussiness.ReadDataDelegate;
	import ericXie.com.interfaces.IDataResponder;
	import ericXie.com.model.MainModel;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.net.URLLoader;

	
	/**
	 * ...加载XML数据
	 * @author EricXie
	 */
	public class ReadDataCommand implements ICommand, IDataResponder 
	{
		private var _delegate:ReadDataDelegate;
		private var _model:MainModel = MainModel.getInstance();
		private var path:String;
		
		public function ReadDataCommand() 
		{
			_delegate = new ReadDataDelegate(this);
		}
		public function execute(event:CairngormEvent):void
		{
			var obj:Object = event.data;
			_delegate.readConfig(obj);
			path = obj.path;
			
		}
		public function progress(evt:ProgressEvent):void
		{
			
		}
		public function result(evt:Event):void
		{
			var loader:URLLoader = URLLoader(evt.target)
			var str:String = String(loader.data);
			str = "1,3,获得小猫奖品,http://www.sina.com.cn";
			_model.getData = str.split(",");
		}
		
		public function fault(evt:IOErrorEvent):void
		{
			trace(evt.text)
		}
		
	}

}